package gov.dhs.cis.soa.readers.reqpro.xmind;

import java.util.ArrayList;
import java.util.List;

public class XMindObject {
	public static enum TYPE { PROJECT, SHEET, TOPIC, CHILDTOPIC };
	
	public TYPE objType;
	public String id;
	public String name;
	public String descText;
	public String prefix;
	
	public List<XMindObject> children;
	
	public XMindObject() {
		objType = TYPE.CHILDTOPIC;
		name = "";
		children = new ArrayList<XMindObject>();
	}

	public XMindObject(String name) {
		objType = TYPE.CHILDTOPIC;
		this.name = name;
		children = new ArrayList<XMindObject>();
	}
	public XMindObject(TYPE oType) {
		objType = oType;
		this.name = "";
		children = new ArrayList<XMindObject>();
	}
	public XMindObject(TYPE oType, String name) {
		objType = oType;
		this.name = name;
		children = new ArrayList<XMindObject>();
	}
	
	public XMindObject(XMindObject copyOf) {
		objType = copyOf.objType;
		name = copyOf.name;
		descText = copyOf.descText;
		prefix = copyOf.prefix;
		
		children = new ArrayList<XMindObject>();
		if(copyOf.children != null && copyOf.children.size() > 0) {
			for(XMindObject cc_child : copyOf.children) {
				this.addChild(new XMindObject(cc_child));
			}
		}
	}
	
	public void addChild(XMindObject child) {
		if(child == null)
			return;
		if(child.objType == TYPE.PROJECT) {
			System.out.println("Trying to add a PROJECT element ad child, ignoring : " + child.name);
			return;
		}
		if(this.children == null)
			this.children = new ArrayList<XMindObject>();
		this.children.add(child);
	}
	
	@Override
	public String toString() {
		return (id + "[" + children + "]");
	}
}
